<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue中的Component</title>
</head>
<body>
    <div id="app">
      <button @click="a='aaa'">aaa组件</button>
      <button @click="a='bbb'">bbb组件</button>
      <component v-bind:is='a'></component>
    </div>
    <script src="node_modules/vue/dist/vue.js"></script>
    <script>

      new Vue({
          el: "#app",
          data: {
              a: 'aaa'
          },
          components: {
              aaa: {
                  template: '<h2>我是aaa组件</h2>'
              },
              bbb: {
                  template: '<h2>我是bbb组件</h2>'
              }
          }
      });

    </script>
</body>
</html>